namespace Nico {

    [GtkTemplate (ui="/de/grindhold/nico/ui/nico_client_app_session.ui")]
    public class SessionView : Gtk.Box {

        [GtkChild]
        public Gtk.Label time;

        [GtkChild]
        public Gtk.Label date;

        [GtkChild]
        public Gtk.Label location;

        [GtkChild]
        public Gtk.Label tabak;

        [GtkChild]
        public Gtk.Label lighter;

        [GtkChild]
        public Gtk.Label filter;

        [GtkChild]
        public Gtk.Label papes;

        [GtkChild]
        public Gtk.Button button;

        [GtkChild]
        public Gtk.ListBox user_list;

        public int id;
        private Nico.Session session;

        public SessionView(Nico.Session session) {
		  this.id = session.id;
		  this.session = session;
          this.update( this.session);
		  
		}

        public void update(Nico.Session session) {
		  this.papes.label    = session.resources.papes ? "Papes" : "";
          this.filter.label   = session.resources.filter ? "Filter" : "";
          this.lighter.label  = session.resources.lighter ? "Lighter" : "";
          this.tabak.label    = session.resources.tabak ? "Tabak" : "";
          this.location.label = session.location;
          this.time.label     = this.getTimeString(session.datetime);
          this.date.label     = this.getDateString(session.datetime);
		  }

        private string getTimeString(string datetime) {
			return datetime.substring(11, 5) + " Uhr";
        }

        private string getDateString(string dateTime) {
			string date = dateTime.substring(8, 2) + ".";
			date += dateTime.substring(5, 2) + ".";
			date += dateTime.substring(0, 4);
            return date;
        }

		[GtkCallback]
		public void join_session() {
		
		}
    }
}
